package io.renren.modules.sp.controller.front;

import com.alibaba.fastjson.JSONObject;
import io.renren.common.redis.RedisUtils;
import io.renren.modules.sp.dto.SpUserDTO;
import org.springframework.beans.factory.annotation.Autowired;

import javax.servlet.http.HttpServletRequest;


/**
 * 基础controller
 *
 * @author whc 15953295779@126.com
 * @since 3.0 2022-04-22
 */
public class FrontBaseController {

    @Autowired
    private RedisUtils redisUtils;

    public SpUserDTO getFrontUserInfo(HttpServletRequest request) {
        String token = request.getHeader("tokenid");
        String key = "USER:" + token;
        String userInfoStr = (String) redisUtils.get(key);
        return JSONObject.parseObject(userInfoStr, SpUserDTO.class);
    }


}
